<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

</body>


<script type="text/javascript">
  let reverse = function (x) {
    let a = ''
    if ( x < 0 ) a = '-'
    let data = Math.abs(x).toString().split('')
    if ( data.length < 2 ) return x
    if ( data.length >= 32 ) return 0

    a = a + Number(data.reverse().join(''))
    if ( a > (Math.pow(2, 31) - 1) || a < Math.pow(-2, 31) ) {
      return 0
    } else{
      return a
    }
  };

  console.log(reverse(-4523));
</script>
</html>